<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="UTF-8">
<title>考试添加</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="../../static/lib/layui/css/layui.css" th:href="@{/lib/layui/css/layui.css}" media="all">
<script src="../../static/lib/layui/layui.js" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script src="../../static/lib/jquery/jquery-3.2.1.min.js" th:src="@{/lib/jquery/jquery-3.2.1.min.js}"></script>
<script src="../../static/js/common/public.js" th:src="@{/js/common/public.js}"></script>
<script src="../../static/lib/jquery/easysector.1.0.0.js" th:src="@{/lib/jquery/easysector.1.0.0.js}"></script>
<style type="text/css">
    .form-padding {
        padding: 10px;
    }

</style>
</head>
<body>
<form class="layui-form form-padding" id="search-form">
    <div class="layui-form-item">
        <label class="layui-form-label">班级编号</label>
        <div class="layui-input-inline">
            <input type="text" name="classId" autocomplete="on"
                   class="layui-input">
        </div>
        <label class="layui-form-label">考试组号</label>
        <div class="layui-input-inline">
            <input type="text" name="examGroupId" required autocomplete="on"
                   class="layui-input">
        </div>
        <label class="layui-form-label">最低分</label>
        <div class="layui-input-inline">
            <input type="text" name="minScore" required autocomplete="on"
                   class="layui-input">
        </div>
        <label class="layui-form-label">最高分</label>
        <div class="layui-input-inline">
            <input type="text" name="maxScore" required autocomplete="on"
                   class="layui-input">
        </div>
        <label class="layui-form-label">粒度</label>
        <div class="layui-input-inline">
            <input type="text" name="granularity" required autocomplete="on"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <div class="layui-btn" id="submit">搜索</div>
        </div>
    </div>
</form>

<table id="list" lay-filter="data-table"></table>
<div style="float:right;width:500px"><div id="easysector"></div>
<script type="application/javascript" th:inline="none">
    (function () {
        let layer;
        layui.use('element', function () {
            var element = layui.element;
        });
        layui.use('form', function () {
            /*var form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function (data) {
                layer.msg(JSON.stringify(data.field));
                return false;
            });*/
        });

        layui.use('layer', function () {
            layer = layui.layer;
        });

        function bindAction() {
            $('#submit').click(function () {
                search(constructArgs($('#search-form')))
            })
        }

        function search(param) {
            $.ajax({
                url: '/inside/score/inside/analyzeTotalScoreScale'
                , data: param
                , success: function (data) {
                    if (data.status == 0) {
                        render(data.data);
                        $('#easysector').html('');
                        let datum = data.data[1][0];
                        let bili = new Array();
                        let i = 0;
                        for (let item in datum) {
                            if (item.startsWith('scale')) {
                                let o ={};
                                o.h_title=item;
                                o.h_amount=datum[item];
                                // let hColor = yuv2rgb(Math.floor(Math.random()*256),Math.floor(Math.random()*256),Math.floor(Math.random()*256));
                                let hColor = color16();
                                o.h_color= hColor
                                i++;
                                bili.push(o);
                            }
                        }
                        drawCircle(bili)
                    } else {
                        layer.msg(data.description)
                    }
                }
            })
        }

        function render(data) {
            let table = null;
            layui.use('table', function () {
                table = layui.table;
                table.render({
                    elem: '#list'
                    //,width: 900
                    //,height: 274
                    , cellMinWidth: 100
                    , cols: [data[0]]
                    , skin: 'row' //表格风格
                    , even: true
                    //,size: 'lg' //尺寸
                    ,data:data[1]
                    , page: true //是否显示分页
                    //, limits: [3, 5, 10]
                    , limit: 10 //每页默认显示的数量
                    , loading: false //请求数据时，是否显示loading
                });
            });
        };
        function color16(){//十六进制颜色随机
            var r = Math.floor(Math.random()*256);
            var g = Math.floor(Math.random()*256);
            var b = Math.floor(Math.random()*256);
            var color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
            return color;
        }
        function drawCircle(h_items) {
            $("#easysector").easysector({
                "h_items": h_items,
                "h_title": "Browser Percent",
                "h_width": 260,
                "h_borderColor":"silver",
                "h_poindlength": 0,
                //"h_showamount": true,
                "h_backColor":"#eee",
                "h_recwidth": 20,
                "h_titlesize": 24,
                "h_Radii": 125,
                "h_infosize":16
            });
        }
        bindAction();
    })()

</script>
</body>
</html>